home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / GEDEV100.ZIP;1 / PASCAL.ZIP / GE_DEMO.PAS next >
Encoding:
Pascal/Delphi Source File  |  1992-10-12  |  3.7 KB  |  151 lines

  1. (*
  2. **  GEcho 1.00 Developers Kit Demonstration Source Code
  3. **
  4. **  Written by Gerard J. van der Land
  5. **
  6. **  Copyright (C) 1992 Gerard J. van der Land. All rights reserved.
  7. **
  8. **  Last updates: 12-Oct-92
  9. *)
  10.  
  11. {$I gestruct.inc}
  12. {$L pascal.obj}
  13.  
  14. var
  15.    sys         : SETUP_GE;
  16.    AreaHdr     : AREAFILE_HDR;
  17.    AreaFile    : AREAFILE_GE;
  18.    AreaIdx     : array[1..MAXAREAS] of AREAFILE_GEX;
  19.    SetupGE     : file;
  20.    AreaFileGE  : file;
  21.    AreaFileGEX : file;
  22.    result      : word;
  23.    records     : word;
  24.    areas       : word;
  25.    arearecsize : word;
  26.    counter     : word;
  27.    buffer      : string[255];
  28.  
  29. procedure c2p(dest : string ; src : pointer; max : byte); external;
  30. procedure p2c(dest : pointer; src : string ; max : byte); external;
  31.  
  32. begin
  33.  
  34. (*
  35. **  Opening and reading SETUP.GE
  36. *)
  37.  
  38. {$I-}
  39.    assign(SetupGE, 'SETUP.GE');
  40.    reset(SetupGE, 1);
  41. {$I+}
  42.    if IOresult <> 0 then
  43.    begin
  44.       writeln('Unable to open SETUP.GE');
  45.       halt(255)
  46.    end;
  47.    blockread(SetupGE, sys, sizeof(SETUP_GE), result);
  48.    close(SetupGE);
  49.    if result < sizeof(SETUP_GE) then
  50.    begin
  51.       writeln('Error reading SETUP.GE');
  52.       halt(255)
  53.    end;
  54.    if (sys.sysrev <> GE_THISREV) then
  55.    begin
  56.       writeln('System file revision level mismatch\n');
  57.       halt(251)
  58.    end;
  59.  
  60.    c2p(buffer, @sys.username[1], 35);  (* C -> Pascal *)
  61.    writeln('SysOp: ', buffer);
  62.    p2c(@sys.username[1], 'gerard van.der.land', 35);  (* Pascal -> C *)
  63.  
  64. (*
  65. **  Opening AREAFILE.GE and checking the header
  66. *)
  67.  
  68. {$I-}
  69.    assign(AreaFileGE, 'AREAFILE.GE');
  70.    reset(AreaFileGE, 1);
  71. {$I+}
  72.    if IOresult <> 0 then
  73.    begin
  74.       writeln('Unable to open AREAFILE.GE');
  75.       halt(255)
  76.    end;
  77.    blockread(AreaFileGE, AreaHdr, sizeof(AREAFILE_HDR), result);
  78.    if result < sizeof(AREAFILE_HDR) then
  79.    begin
  80.       writeln('Error reading AREAFILE header');
  81.       halt(255)
  82.    end;
  83.  
  84.    if AreaHdr.recsize < sizeof(AREAFILE_GE) then
  85.    begin
  86.       writeln('Incompatible AREAFILE record size');
  87.       halt(255)
  88.    end;
  89.  
  90. (*
  91. **  Reading AREAFILE.GE
  92. **
  93. **  Method 1: Using AREAFILE.GEX index file
  94. **  This will read the area records in alphabetical order, removed area
  95. **  records are automatically skipped.
  96. *)
  97.  
  98. {$I-}
  99.    assign(AreaFileGEX, 'AREAFILE.GEX');
  100.    reset(AreaFileGEX, 1);
  101. {$I+}
  102.    if IOresult <> 0 then
  103.    begin
  104.       writeln('Unable to open AREAFILE.GEX');
  105.       halt(255)
  106.    end;
  107.    blockread(AreaFileGEX, AreaIdx, sizeof(AreaIdx), result);
  108.    areas := result div sizeof(AREAFILE_GEX);
  109.  
  110.    for counter := 1 to areas do
  111.    begin
  112.       seek(AreaFileGE, AreaIdx[counter].offset);
  113.       blockread(AreaFileGE, AreaFile, sizeof(AREAFILE_GE), result);
  114.       if result = sizeof(AREAFILE_GE) then
  115.       begin
  116.          c2p(buffer, @AreaFile.name, 50);
  117.          writeln(counter, ' ' , buffer)
  118.       end
  119.    end;
  120.  
  121. (*
  122. **  Reading AREAFILE.GE
  123. **
  124. **  Method 2: Sequentially reading
  125. **  This will read the area records in the order in which they area stored.
  126. **  You will have to check each record to see if it has been removed.
  127. *)
  128.  
  129.    arearecsize := AreaHdr.systems * sizeof(EXPORTENTRY) + AreaHdr.recsize;
  130.    records := (filesize(AreaFileGE) - AreaHdr.hdrsize) div arearecsize;
  131.    areas := 0;
  132.    for counter := 0 to records-1 do
  133.    begin
  134.       seek(AreaFileGE, AreaHdr.hdrsize + longint(arearecsize) * longint(counter));
  135.       blockread(AreaFileGE, AreaFile, sizeof(AREAFILE_GE), result);
  136.       if result = sizeof(AREAFILE_GE) then
  137.       begin
  138.          if (AreaFile.options and REMOVED) = 0 then
  139.          begin
  140.             inc(areas);
  141.             c2p(buffer, @AreaFile.name, 50);
  142.             writeln(areas, ' ' , buffer)
  143.          end
  144.       end
  145.    end;
  146.    close(AreaFileGE);
  147.  
  148. end.
  149.  
  150. (* end of file "ge_demo.pas" *)
  151.